package com.ssy.lingxi.system.controller;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.PageModel;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.system.dto.request.SiteAddRequest;
import com.ssy.lingxi.system.dto.request.SiteDetailsResquest;
import com.ssy.lingxi.system.dto.request.SiteUpdateResquest;
import com.ssy.lingxi.system.dto.request.SiteUpdateStateResquest;
import com.ssy.lingxi.system.dto.response.SiteAllResponse;
import com.ssy.lingxi.system.dto.response.SiteDetailsResponse;
import com.ssy.lingxi.system.dto.response.SiteListResponse;
import com.ssy.lingxi.system.service.SiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
 * @menu 基础设置-站点管理
 * @author wrc
 * @date 2020/7/20
 */
@Api(tags = "站点管理")
@RestController
public class SiteController {


    @Resource
    SiteService siteService;

    @ApiOperation(value = "添加站点")
    @PostMapping("/site/add")
    public Wrapper siteAdd(@RequestBody  SiteAddRequest request,HttpServletRequest httpServletRequest) {
        return siteService.siteAdd(httpServletRequest,request);
    }

    @ApiOperation(value = "查询站点列表")
    @GetMapping("/site/list")
    public Wrapper<PageData<SiteListResponse>> siteList(PageModel request) {
        return siteService.siteList(request);
    }

    @ApiOperation(value = "查询站点详情")
    @GetMapping("/site/details")
    public Wrapper<SiteDetailsResponse> siteDetails(SiteDetailsResquest request) {
        return siteService.siteDetails(request);
    }

    @ApiOperation(value = "删除站点")
    @PostMapping("/site/delete")
    public Wrapper siteDelete(@RequestBody   SiteDetailsResquest request) {
        return siteService.siteDelete(request);
    }

    @ApiOperation(value = "修改站点")
    @PostMapping("/site/update")
    public Wrapper siteUpdate(@RequestBody  SiteUpdateResquest request) {
        return siteService.siteUpdate(request);
    }

    @ApiOperation(value = "查询所有站点")
    @GetMapping("/site/all")
    public Wrapper<List<SiteAllResponse>> siteAll() {
        return siteService.siteAll();
    }

    @ApiOperation(value = "修改站点状态")
    @PostMapping("/site/update/state")
    public Wrapper siteUpdateState(@RequestBody SiteUpdateStateResquest request) {
        return siteService.siteUpdateState(request);
    }

    @ApiOperation(value = "根据模板查询所有站点")
    @GetMapping("/site/allByTemplate")
    public Wrapper<List<SiteAllResponse>> allByTemplate(Long templateId) {
        return siteService.allByTemplate(templateId);
    }
}
